package com.qiyuexinxi.chat.controller;

import com.qiyuexinxi.chat.common.GenericResponse;
import com.qiyuexinxi.chat.constants.api.DynamicApi;
import com.qiyuexinxi.chat.dto.request.DynamicAddRequest;
import com.qiyuexinxi.chat.dto.request.DynamicDeleteRequest;
import com.qiyuexinxi.chat.dto.request.GetDynamicListRequest;
import com.qiyuexinxi.chat.dto.request.GetDynamicListSexRequest;
import com.qiyuexinxi.chat.service.impl.DynamicServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.websocket.server.PathParam;

@RestController
@Api(description = "动态相关接口")
public class DynamicController {

    @Autowired
    DynamicServiceImpl dynamicService;

    @PostMapping(value = DynamicApi.ADD_DYNAMIC, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "发布动态", notes = "发布动态")
    public GenericResponse addDynamic(@Valid @RequestBody DynamicAddRequest dynamicAddRequest){
        return new GenericResponse(dynamicService.addDynamic(dynamicAddRequest));
    }

    @PostMapping(value = DynamicApi.DELETE_DYNAMIC, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除动态", notes = "删除动态")
    public GenericResponse deleteDynamic(@Valid @RequestBody DynamicDeleteRequest dynamicDeleteRequest){
        return new GenericResponse(dynamicService.deleteDynamic(dynamicDeleteRequest));
    }

    @PostMapping(value = DynamicApi.GET_DYNAMIC_LIST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "我的动态列表", notes = "我的动态列表")
    public GenericResponse getDynamicList(@Valid GetDynamicListRequest getDynamicListRequest){
        return new GenericResponse(dynamicService.getDynamicList(getDynamicListRequest));
    }

    @PostMapping(value = DynamicApi.GET_DYNAMIC_ATTENTION_LIST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "我关注的动态列表", notes = "我关注的动态列表")
    public GenericResponse getDynamicAttentionList(@Valid GetDynamicListRequest getDynamicListRequest){
        return new GenericResponse(dynamicService.getDynamicAttentionList(getDynamicListRequest));
    }

    @PostMapping(value = DynamicApi.GET_ALLDYNAMIC_LIST_BYSEX, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据性别获取同一性别所有人的动态列表", notes = "根据性别获取同一性别所有人的动态列表")
    public GenericResponse getAllDynamicListBySex(@Valid GetDynamicListSexRequest getDynamicListSexRequest){
        return new GenericResponse(dynamicService.getAllDynamicListBySex(getDynamicListSexRequest));
    }
}
